/**
 * This file is part of the CAKIS project.
 * 
 * Copyright (c) 2009-2010 - Florian Arndt, Christian Kerl
 * 
 * @license GNU Lesser General Public License v3 <http://www.opensource.org/licenses/lgpl-3.0.html>
 * @since   04.05.2010
 * @version SVN: $Id: OfflineBarcodeHandler.java 155 2010-05-19 13:51:47Z f.aarndt@web.de $
 */

package org.cakis.client;

import javax.microedition.rms.RecordStore;


import com.google.zxing.client.result.ParsedResult;

/**
 * OfflineBarcodeHandler
 *
 * @author Florian Arndt
 */
public class OfflineBarcodeHandler {
	private boolean flag;
	private RecordStore barcodeStore;
	
	public OfflineBarcodeHandler () {
		this.flag = true;
	}
	
	public void setFlag(boolean flag) {
		this.flag = flag;
	}
	
	public boolean getFlag () {
		return flag;
	}
	
	public void setBarcodeToRecordStore(ParsedResult result) {
		try {
			System.out.println(result.toString());
			barcodeStore = RecordStore.openRecordStore("barcodeStore", true);
			barcodeStore.addRecord(result.toString().getBytes(), 0, result.toString().getBytes().length);
			System.out.println(barcodeStore.getNumRecords());
			barcodeStore.closeRecordStore();
		} catch (Exception e) {
			e.printStackTrace();
		} 
	}
	
}
